package com.qf.application.utils.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code;
    private String message;
    private Object data;

    public static Result success(){
        Result success = new Result();
        success.setCode(200);
        return success;
    }

    public static Result success(Object data){
        Result success = success();
        success.setCode(200);
        success.setMessage("ok");
        success.setData(data);
        return success;
    }

    public static Result success(String msg){
        Result success = success();
        success.setMessage(msg);
        success.setData(null);
        success.setCode(200);
        return success;
    }

    public static Result success(Object data,String msg){
        Result success = success();
        success.setMessage(msg);
        success.setData(data);
        return success;
    }

    public static Result error (Integer code , String msg){
        Result error = new Result();
        error.setMessage(msg);
        error.setCode(code);
        return error;
    }

}
